<template>
	<view class="">
		<view class="newcar_parameter_container">
			<view class="newcar_par_l">
				<view class="newcar_par_ycxt">
					<u-switch v-model="checked" active-color="#002a58" @change="ycxt"></u-switch>
					<view class="new-hader-title-text">隐藏相同</view>
				</view>
				<view class="newcar_par_leftbox" v-for="(item1,index1) in configList" :key="index1">
					<view class="newcar_par_title" v-if="item1.confignData.length!=0">
						<view class="" style="font-weight:bold">
							{{item1.confignName}}
						</view>
						<view class="newcar_par_title_desc">
							<view class="newcar_par_title_desc_bp"><text>●</text> 标配</view>
							<view class="newcar_par_title_desc_bp"><text>○</text> 选配</view>
							<view class="newcar_par_title_desc_bp"><text>-</text> 无</view>
						</view>
					</view>

					<view class="newcar_par_smtitle" v-if="item1.confignData.length!=0">
						<view class="newcar_par_smtitle_box">
							<view class="newcar_par_smtitle_item" v-for="(item2,index2) in item1.confignData"
								:key="index2">
								{{item2.name}}
							</view>
						</view>
					</view>

				</view>
			</view>
			<!--  -->
			<view class="newcar_par_r" style="overflow-x: scroll;">
				<view class="newcar_par_model">
					<view class="car_model" v-for="(item,index) in carModelList" :key="index">
						<view class="scroll-item-icon" v-if="carModelList.length > 2" @click="deleteCarModel(index)">
							<u-icon name="close-circle-fill" color="red" size="36"></u-icon>
						</view>
						<view class="scroll-item-text">{{item}}</view>
						<view class="scroll-item-btn" @click="goUsedCar(item,index)">查看二手车</view>
					</view>
				</view>

				<view class="newcar_par_content">
					<view class="newcar_par_box" v-for="(item11,index11) in configList" :key="index11"
						v-if="item11.confignData.length!=0">
						<view class="newcar_par_item_box" v-for="(item21,index21) in item11.confignData" :key="index21">
							<view class="newcar_par_item" v-for="(item3,index3) in item21.value" :key="index3"
								v-if="item21.value">
								<view class="" v-if="item21.isColor">
									<u-parse :content="item3 ? item3 : '-'"></u-parse>
								</view>
								<view class="" v-else>
									{{item3 ? item3 : '-'}}
								</view>
							</view>
						</view>
					</view>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import API from "@/api/buycar.js"
	import uParse from '@/components/u-parse/u-parse.vue'
	export default {
		components: {
			uParse
		},
		onLoad(option) {
			console.log(option);
			this.seriesId = option.seriesId;
		},
		onShow() {
			this.getCarModelConfigList()
		},
		data() {
			return {
				// article: '<div>我是HTML代码</div>',
				checked: false,
				scrollLeft: 0,
				current: 0,
				list: [],
				configList: [],
				carModelList: [],
				notModelIdslist: [],
				notModelIds: "",
				delSame: false,
				usedCarId: "",
				seriesId: "",
				colorList: []
			}
		},

		methods: {

			deleteCarModel(index) {
				console.log(index);
				this.notModelIdslist.push(this.list[0].modelIds[index]);
				this.notModelIds = this.notModelIdslist.join(",")
				console.log(this.notModelIds);
				this.getCarModelConfigList();
			},
			goUsedCar(item, index) {
				console.log(index);
				this.usedCarId = this.list[0].modelIds[index];
				uni.navigateTo({
					url: `/pagesA/buyCar/buyCar?seriesId=${this.usedCarId}&brandId=${this.seriesId}&seriesName=${item}`
				})

			},
			ycxt(e) {
				this.delSame = e
				this.getCarModelConfigList()
			},

			getCarModelConfigList() {
				let data = {
					seriesId: this.seriesId,
					// seriesId: '11427',
					notModelIds: this.notModelIds,
					delSame: this.delSame
				}
				API.getCarModelConfigList(data).then(res => {
					console.log(res);
					this.list = res.data;
					this.carModelList = this.list[0].modelNames;
					this.configList = this.list.slice(1);
					console.log(this.configList);

				})
			},
			scroll: function(e) {
				console.log(e.detail.scrollLeft)
				this.$nextTick(() => {
					this.scrollLeft = e.detail.scrollLeft
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url("@/components/u-parse/u-parse.css");

	.newcar_parameter_container {
		border-top: 1rpx solid #f3f3f3;
		position: relative;
		font-size: 24rpx;
		box-sizing: border-box;

		.newcar_par_l {
			width: 200rpx;
			float: left;
			background-color: #fafafa;

			.newcar_par_ycxt {
				width: 200rpx;
				height: 260rpx;
				border-bottom: 1rpx solid #f3f3f3;
				border-right: 1rpx solid #f3f3f3;
				text-align: center;
				padding-top: 50rpx;
				background: #fff;
				box-sizing: border-box;

				// position: fixed;
				// left: 0;
				// top:0;
				//             z-index: 100;
				.new-hader-title-text {
					display: block;
				}
			}

			// .newcar_par_leftbox{
			// 	margin-top:261rpx;

			// }

			.newcar_par_title {
				width: 100%;
				height: 80rpx;
				font-size: 30rpx;
				background: #fff;
				display: flex;
				align-items: center;
				justify-content: center;
				border-right: 1rpx solid #fff;

				position: relative;
				z-index: 10000;

				.newcar_par_title_desc {
					position: absolute;
					left: 500rpx;
					width: 300rpx;
					height: 80rpx;
					font-size: 26rpx;
					background: #fff;
					display: flex;
					align-items: center;

					.newcar_par_title_desc_bp {
						margin-left: 10rpx;
					}
				}
			}

			.newcar_par_smtitle {
				border-top: 1px solid #f3f3f3;
				box-sizing: border-box;

				.newcar_par_smtitle_item {
					width: 100%;
					height: 110rpx;
					line-height: 30rpx;
					display: flex;
					align-items: center;
					padding: 0 10rpx;
					font-size: 24rpx;
					box-sizing: border-box;
					border-right: 1rpx solid #f3f3f3;
					border-bottom: 1rpx solid #f3f3f3;
					box-sizing: border-box;
				}
			}
		}

		.newcar_par_r {
			width: calc(100%-200rpx);
			background: #fff;
			height: auto;

			// overflow-x: scroll;
			.newcar_par_model {
				width: auto;
				height: 260rpx;
				display: flex;
				align-items: center;
				flex-wrap: nowrap; //不换

				//             position: fixed;
				// right:0;
				// top:0;
				.car_model {
					width: 280rpx;
					height: 100%;
					padding: 40rpx 20rpx 30rpx 20rpx;
					flex-shrink: 0;
					box-sizing: border-box;
					position: relative;
					background-color: #fff;
					border-right: 1rpx solid #f3f3f3;
					border-bottom: 1rpx solid #f3f3f3;

					.scroll-item-icon {
						position: absolute;
						right: 10rpx;
						top: 10rpx;
					}

					.scroll-item-text {
						text-align: center;
						font-size: 28rpx;
						color: #333;
						line-height: 35rpx;
						height: 105rpx;
					}

					.scroll-item-btn {
						width: auto;
						margin-top: 20rpx;
						font-size: 28rpx;
						color: #fff;
						background-color: #ff9d40;
						border-radius: 6rpx;
						line-height: 50rpx;
						text-align: center;
					}
				}
			}
		}

		.newcar_par_content {
			.newcar_par_box {
				margin-top: 80rpx;
				border-bottom: 1rpx solid #f3f3f3;

				.newcar_par_item_box {
					width: auto;
					height: 110rpx;
					line-height: 30rpx;
					display: flex;
					align-items: center;
					flex-wrap: nowrap; //不换
					border-top: 1rpx solid #f3f3f3;
					box-sizing: border-box;

					.newcar_par_item {
						width: 280rpx;
						height: 100%;
						padding: 0 20rpx;
						flex-shrink: 0;
						display: flex;
						align-items: center;
						box-sizing: border-box;
						border-right: 1rpx solid #f3f3f3;
						overflow: hidden;
						// border-bottom: 1rpx solid #f3f3f3;

						box-sizing: border-box;

					}
				}
			}
		}
	}



	.new-car-dep {
		border-top: 1rpx solid #f3f3f3;
		position: relative;

		.new-hader {
			display: flex;
			justify-content: space-between;
			align-items: stretch;
			background-color: #fff;
			border-bottom: 1rpx solid #f3f3f3;
			width: 100%;
			height: 270rpx;
			position: fixed;

			.new-hader-title {
				width: 200rpx;
				text-align: center;
				height: 270rpx;
				padding: 80rpx 0rpx;
				box-sizing: border-box;
				border-right: 1rpx solid #f3f3f3;
			}

			.scroll-car {
				flex: 1;
				overflow: hidden;
				box-sizing: border-box;
				white-space: nowrap;

				.new-car-List {
					display: flex;
					align-items: center;
					flex-wrap: nowrap; //不换行
					box-sizing: border-box;
					height: 270rpx;

					.scroll-item {
						width: 280rpx;
						flex-shrink: 0;
						padding: 24rpx;
						box-sizing: border-box;
						text-align: center;
						border-right: 1rpx solid #f3f3f3;

						&:last-of-type {
							border-right: none;
						}

						.scroll-item-icon {
							text-align: right;
							margin-bottom: 20rpx;
						}

						.scroll-item-text {
							text-align: center;
							margin-top: 8rpx;
							font-size: 30rpx;
							color: #333;
						}

						.scroll-item-btn {
							margin-top: 20rpx;
							font-size: 28rpx;
							color: #fff;
							background-color: #ff9d40;
							border-radius: 6rpx;
							line-height: 50rpx;
							text-align: center;
						}
					}
				}
			}
		}

		.dep-cont {
			position: fixed;
			top: 274rpx;
			left: 0;
			right: 0;
			bottom: 0;

			.scroll-y_cont {
				height: 100%;

				.new-model {
					background-color: #fff;
					border-bottom: 1rpx solid #f3f3f3;

					.new-model-title {
						display: flex;
						justify-content: space-between;
						align-items: center;
						color: #333;
						padding: 24rpx;
						box-sizing: border-box;

						.model-top-title {
							flex: 1;
							font-size: 30rpx;
							font-weight: bolder;
						}

						.model-top-r {
							display: flex;
							align-items: center;

							.model-top-r-t {
								font-size: 28rpx;

								text {
									font-size: 36rpx;
									margin-right: 10rpx;
									margin-left: 30rpx;
								}
							}
						}
					}

					.new-model-item {
						display: flex;
						justify-content: space-between;
						align-items: center;
						border-top: 1rpx solid #f3f3f3;

						// ==================================================
						.swiper {
							flex: 1;
							width: 100%;
							height: 300rpx;

							.swiper-item {
								color: #fff;
								height: 300rpx;
							}

							.uni-bg-red {
								background-color: #007AFF;
							}

							.uni-bg-green {
								background-color: #19BE6B;
							}

							.uni-bg-blue {
								background-color: #002A55;
							}
						}

						// ====================================================



						.new-model-item_l {
							width: 200rpx;
							text-align: center;
							font-size: 28rpx;
							color: #333;
							padding: 24rpx;
							box-sizing: border-box;
							background-color: #f8f8f8;
							border-top: 1rpx solid #f3f3f3;
						}

						.scroll-model {
							flex: 1;
							overflow: hidden;
							box-sizing: border-box;
							white-space: nowrap;
							position: relative;

							.new-model-item_r {
								display: flex;
								align-items: center;
								flex-wrap: nowrap; //不换行
								box-sizing: border-box;

								.item-text {
									width: 280rpx;
									flex-shrink: 0;
									padding: 24rpx;
									box-sizing: border-box;
									text-align: center;
									border-top: 1rpx solid #f3f3f3;
									border-right: 1rpx solid #f3f3f3;
								}
							}
						}

					}
				}
			}
		}
	}
</style>
